// house_pkg/pages/room/index.ts
Page({
  data: {
    point: '',
    building: '',
    room: []

  },
  /**
 * 生命周期函数--监听页面加载
 */
  onLoad({ point, building }) {
    // point 小区名
    // building 楼栋
    // console.log(point, building);
    // 循环产生 房间号
    const room = []
    for (let index = 0; index < 6; index++) {
      room.push(`${this.getRandom(1, 9)}${this.getRandom(1, 6)}${this.getRandom(1, 7)}`)
    }
    // 排序
    room.sort((a, b) => {
      a = +a
      b = +b
      return a - b > 0 ? 1 : -1
    })
    this.setData({
      point,
      building,
      room
    })
  },
  // 产生随机数字
  getRandom(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min
  }
})